﻿@model Model.tb_attachment
@{
    Layout = null;
}

<!DOCTYPE html>

<head>
    <meta name="viewport" content="width=device-width" />
    <title>卫生与票据</title>
    <link rel="stylesheet" type="text/css" href='@Url.Content("~/Scripts/jquery-easyui/themes/default/easyui.css")'>
    <link rel="stylesheet" type="text/css" href='@Url.Content("~/Scripts/jquery-easyui/themes/icon.css")'>
    <link rel="stylesheet" type="text/css" href='@Url.Content("~/Scripts/jquery-easyui/demo.css")'>
    <link rel="stylesheet" type="text/css" href='@Url.Content("~/Scripts/uploader/uploadify.css")' />
    <script type="text/javascript" src='@Url.Content("~/Scripts/jquery-1.8.2.min.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/jquery-easyui/jquery.easyui.min.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/jquery-easyui/locale/easyui-lang-zh_CN.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/uploader/jquery.uploadify.min.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/uploader/swfobject.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/MicrosoftAjax.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/MicrosoftMvcAjax.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/My97DatePicker/WdatePicker.js")'></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#txt_Search1').click(function () { WdatePicker({ maxDate: '#F{$dp.$D(\'txt_Search2\',{d:-1});}' }) });
            $('#txt_Search2').click(function () { WdatePicker({ minDate: '#F{$dp.$D(\'txt_Search1\',{d:1});}' }) });
            click_Search();
        });

        function click_Delete(_itemId) {
            if (confirm("确定要删除数据吗？")) {
                $.getJSON("/Supplier/Delete_SupplierItem/" + _itemId, function (data) { alert(data); if (data == "删除成功！") { $('#dgtable').datagrid('reload'); } });
            }
        }
        function click_Edit(_itemId) {
            window.parent.mainFrame.location.href = '@Url.Action("doSanitationInfo", "Supplier")' + "?_supplierId=@ViewBag._supplierId&id=" + _itemId;
        }

        function click_Search() {
            var ddl_search = $('#ddl_search').val();
            if (ddl_search == "车辆卫生" || ddl_search == "消毒证明") {
                $('#dgtable').datagrid({
                    url: "/Supplier/GetSanitationList",
                    pagination: true,//分页控件  
                    singleSelect: true,//是否单选
                    rownumbers: true,
                    queryParams: { 'pageNumber': 1, 'pageSize': 8, '_searchtext': "", '_searchtype': "", '_supplierId': '@ViewBag._supplierId' },
                    columns: [[
                        {
                            field: 'createDate', title: '日期', width: 150, align: 'center',
                            formatter: function (value, row, index) {
                                if (value == undefined) {
                                    return "";
                                }
                                value = value.substr(0, value.length - 8);
                                return value;
                            }
                        },
                        {
                            field: 'address', title: '文件下载', width: 200, align: 'center',
                            formatter: function (value, row, index) {
                                var wjxz = "";
                                var _type = "";
                                switch (row.type2) {
                                    case "车辆卫生":
                                        _type = "clws";
                                        break;
                                    case "消毒证明":
                                        _type = "xdzm";
                                        break;
                                }
                                wjxz += "<a href='javascript:void(0)' onclick='click_download(" + row.id + ",\"" + _type + "\")' >" + row.type2 + "</a>";
                                return wjxz;
                            }
                        },
                        { field: 'temp2', title: '备注', width: 80, align: 'center' },
                        {
                            field: 'Edit', title: '编辑', width: 40, align: 'center',
                            formatter: function (value, row, index) {
                                return "<a href='javascript:void(0)' onclick='click_Edit(" + row.id + ")' ><img width='18px' height='18' alt='修改' src='../../Content/Images/xiugai.png' /></a>";
                            }
                        },
                        {
                            field: 'Delete', title: '删除', width: 40, align: 'center',
                            formatter: function (value, row, index) {
                                var linkstr = "<a href=\"javascript:void(0)\" onclick=\"click_Delete(" + row.id + ")\" ><img width='18px' height='18' alt=\"删除\" src=\"../../Content/Images/shanchu.png\" /></a>";
                                return linkstr;
                            }
                        }
                    ]]
                });
                var p = $('#dgtable').datagrid('getPager');
                $(p).pagination({
                    pageSize: 10,//每页显示的记录条数，默认为10  
                    pageList: [8, 10, 15, 20],//可以设置每页记录条数的列表  
                    onSelectPage: function (pageNumber, pageSize) {
                        var tablequeryParams = $('#dgtable').datagrid('options').queryParams;
                        tablequeryParams.pageNumber = pageNumber;
                        tablequeryParams.pageSize = pageSize;
                        $('#dgtable').datagrid('options').queryParams = tablequeryParams;
                        $("#dgtable").datagrid("reload");
                    }
                });

            } else if (ddl_search == "检疫证" || ddl_search == "检验报告") {
                $('#dgtable').datagrid({
                    url: "/Supplier/GetSanitationList",
                    pagination: true,//分页控件  
                    singleSelect: true,//是否单选
                    rownumbers: true,
                    queryParams: { 'pageNumber': 1, 'pageSize': 8, '_searchtext': "", '_searchtype': "", '_supplierId': '@ViewBag._lid' },
                    columns: [[
                        {
                            field: 'createDate', title: '日期', width: 150, align: 'center',
                            formatter: function (value, row, index) {
                                if (value == undefined) {
                                    return "";
                                }
                                value = value.substr(0, value.length - 8);
                                return value;
                            }
                        },
                        { field: 'temp1', title: '编号', width: 350, align: 'center' },
                        {
                            field: 'DownLoad', title: '文件下载', width: 200, align: 'center',
                            formatter: function (value, row, index) {
                                var wjxz = "";
                                var _type = "";
                                switch (row.type2) {
                                    case "检疫证":
                                        _type = "jyz";
                                        break;
                                    case "检验报告":
                                        _type = "jybg";
                                        break;
                                }
                                wjxz += "<a href='javascript:void(0)' onclick='click_download(" + row.id + ",\"" + _type + "\")' >" + row.type2 + "</a>";
                                return wjxz;
                            }
                        },
                        { field: 'temp2', title: '备注', width: 80, align: 'center' },
                        {
                            field: 'Edit', title: '编辑', width: 40, align: 'center',
                            formatter: function (value, row, index) {
                                return "<a href='javascript:void(0)' onclick='click_Edit(" + row.id + ")' ><img width='18px' height='18' alt='修改' src='../../Content/Images/xiugai.png' /></a>";
                            }
                        },
                        {
                            field: 'Delete', title: '删除', width: 40, align: 'center',
                            formatter: function (value, row, index) {
                                var linkstr = "<a href=\"javascript:void(0)\" onclick=\"click_Delete(" + row.id + ")\" ><img width='18px' height='18' alt=\"删除\" src=\"../../Content/Images/shanchu.png\" /></a>";
                                return linkstr;
                            }
                        }
                    ]]
                });
                var p = $('#dgtable').datagrid('getPager');
                $(p).pagination({
                    pageSize: 10,//每页显示的记录条数，默认为10  
                    pageList: [8, 10, 15, 20],//可以设置每页记录条数的列表  
                    onSelectPage: function (pageNumber, pageSize) {
                        var tablequeryParams = $('#dgtable').datagrid('options').queryParams;
                        tablequeryParams.pageNumber = pageNumber;
                        tablequeryParams.pageSize = pageSize;
                        $('#dgtable').datagrid('options').queryParams = tablequeryParams;
                        $("#dgtable").datagrid("reload");
                    }
                });
            }
        //var ddls = $("#ddl_search").val();
        var txts1 = $("#txt_Search1").val();
        var txts2 = $("#txt_Search2").val();

        var tablequeryParams = $('#dgtable').datagrid('options').queryParams;
        tablequeryParams._searchtype = ddl_search;
        if (txts1 != null && txts1 != "" && txts2 != null && txts2 != "") {
            tablequeryParams._searchtext = txts1 + "," + txts2;
        }
        $('#dgtable').datagrid('options').queryParams = tablequeryParams;
        $("#dgtable").datagrid("reload");
    }

    function click_download(_itemId, _type) {
        $.ajax({
            url: '@Url.Action("isExists", "Supplier")' + "?id=" + _itemId + "&_type=" + _type,      // 指定调用的URL，对应于Controller  
                type: "GET",                           // 请求类型  
                contentType: "application/json;charset=utf-8",
                dataType: "json",
                success: function (data) {              // 请求成功后的回调  
                    if (data[0] == "true") {
                        window.location.href = '@Url.Action("GetFileFromDisk", "Supplier")' + "?_fileName=" + data[2];
                    } else {
                        return alert("当前文件不存在！");
                    }
                },
                error: function (data) {                // 请求失败后的回调  
                    alert(data.statusText);
                }
            });
        }

        function click_Sanitation(_itemId) {
            $.ajax({
                url: '@Url.Action("isExists", "Supplier")' + "?id=" + _itemId + "&_type=" + _type,      // 指定调用的URL，对应于Controller  
                type: "GET",                           // 请求类型  
                contentType: "application/json;charset=utf-8",
                dataType: "json",
                success: function (data) {              // 请求成功后的回调  
                    if (data[0] == "true") {
                        window.location.href = '@Url.Action("GetFileFromDisk", "Supplier")' + "?_fileName=" + data[2];
                    } else {
                        return alert("当前文件不存在！");
                    }
                },
                error: function (data) {                // 请求失败后的回调  
                    alert(data.statusText);
                }
            });
        }

        function change_type() {

        }

       
    </script>
    <style type="text/css">
        .divList {
            position: absolute;
            top: 40px;
            left: 1px;
            z-index: 99;
            width: 1048px;
        }

        a {
            text-decoration: none;
            color: #000;
        }

            a img {
                border: 0;
            }

        .biaoge {
            width: 1040px;
            font-family: '宋体';
            font-size: 12px;
            color: #10607c;
        }

            .biaoge td {
                text-align: center;
                height: 26px;
                vertical-align: middle;
                border: 1px solid #d4d3d3;
            }
    </style>
</head>
<body style="background-color: transparent; overflow: auto;">
    <div style="background: #faf1e8; height: 30px; width: 100%; top: 1px; position: absolute; z-index: 99; left: 1px;">
        <table align="left" width="100%" height="27px">
            <tr>
                <td width="1029" style="font-family: '宋体'; font-size: 12px; color: #10607c;">当前位置：供应商管理<img style="text-align:center;vertical-align:middle;height:10px" src='@Url.Content("~/Content/Images/位置.png")' />卫生与票据 </td>
            </tr>
        </table>
    </div>

    <div class="divList">
        <table cellpadding="0" cellspacing="0" width="1040px">
            <tr>
                <td>
                    <table cellpadding="0" cellspacing="0" width="1040px">
                        <tr>
                            <td width="130px" style="font-family: '宋体'; font-size: 12px; color: #10607c;">按：      
                                    <select id="ddl_search">
                                        <option value="车辆卫生">车辆卫生</option>
                                        <option value="消毒证明">消毒证明</option>
                                        <option value="检疫证">检疫证</option>
                                        <option value="检验报告">检验报告</option>
                                    </select>
                            </td>
                            <td width="400px" style="font-family: '宋体'; font-size: 12px; color: #10607c;">日期：
                                <input style="border: 1px solid #3496d6;" width="150px" type="text" id="txt_Search1" />
                                至
                                <input style="border: 1px solid #3496d6;" width="150px" type="text" id="txt_Search2" />
                            </td>
                            <td width="160px">
                                <a href="javascript:void(0)" onclick="click_Search()">
                                    <img height="20px" src='@Url.Content("~/Content/Images/chaxun.png")' /></a>
                            </td>
                            <td align="right">
                                <a href="javascript:void(0)" onclick="click_Edit(0)">
                                    <img src='@Url.Content("~/Content/Images/xinzeng.png")' height="20px" /></a>
                                <a href="javascript:void(0)" onclick="history.go(-1)">
                                    <img src='@Url.Content("~/Content/Images/fanhui.png")' height="20px" /></a>
                                
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td>
                    <table cellpadding="0" cellspacing="0" class="biaoge" id="dgtable" height="400px">
                    </table>
                </td>
            </tr>
        </table>
    </div>
</body>
